﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Krist_em_up.Item.Projectiles;
using Microsoft.Xna.Framework;
using Krist_em_up.Characters;

namespace Krist_em_up.Item.Weapons
{
    /// <summary>
    /// Classic but effective, 
    /// Let me introduce you the old school grenade launcher
    /// </summary>
    class GrenadeLauncher : Gun
    {
        public GrenadeLauncher(int owner, Kristemup k)
            : base(owner, k)
        {
            reloadTimer = new TimeSpan(0, 0, 0, 1, 500);
            this.owner = owner;
            this.Name = "Grenade Launcher";
            this.ammunition = 15;
        }

        public override void Shoot(Vector2 position, bool direction)
        {
            if (reloadTimer <= TimeSpan.Zero)
            {
                try
                {
                    Ammunition--;
                    Grenade grenade;
                    if (direction)
                        grenade = new Grenade(owner, game, new Vector2(position.X + Kris.WIDTH, position.Y + Kris.HEIGHT / 2 + 10), new Vector2(1, -1));
                    else
                        grenade = new Grenade(owner, game, new Vector2(position.X, position.Y + Kris.HEIGHT / 2 + 10), new Vector2(-1, -1));
                    game.bullets.Add(grenade);
                }
                catch (NoAmmoException) { }
                this.reloadTimer = new TimeSpan(0, 0, 0, 1, 500);
            }
        }
    }
}
